package Test;



public class 判断平衡二叉树 {
    public boolean isBalanced(TreeNode root) {
        maxDepth(root);
        return is;
    }
    boolean is;
    int maxDepth(TreeNode node){
        if(node==null) return 0;
        int left=maxDepth(node.left);
        int right=maxDepth(node.right);
        if(Math.abs(left-right)>1) is=false;
        return 1+Math.max(left,right);
    }

}
